package com.ubs.training.server.aop;

import com.ubs.training.prod.server.service.LoggingService;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * User: xubuntu
 * Date: 8/24/12
 * Time: 1:21 PM
 * To change this template use File | Settings | File Templates.
 */
@Aspect
@Component
public class TypeAdvice extends AbstractLoggingAdvice {

    @After("execution(* *.saveType(..)) && args(obj2save)")
    public void processSave(Object obj2save) {
        svc.logEvent("AOP Saved product type:" + obj2save.toString());
    }

    @After("execution(* *.*.*.*.*.TypeService.delete(..)) && args(obj2save)")
    public void processDelete(Object obj2save) {
        svc.logEvent("AOP Deleted product type:" + obj2save.toString());
    }

    @After("execution(* *.*.*.*.*.TypeService*.getById(..)) && args(obj2save)")
    public void processGetById(Object obj2save) {
        svc.logEvent("AOP Requested product type with id=" + obj2save.toString());
    }

    @After("execution(* *.*.*.*.*.TypeService.getAll(..))")
    public void processGetAll() {
        svc.logEvent("AOP Requested all product types");
    }



}
